package com.zlp.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.github.pagehelper.PageInfo;
import com.zlp.entity.SysRole;
import com.zlp.entity.SysUser;
import com.zlp.service.SysRoleService;
import com.zlp.service.SysUserService;

@RestController
public class SysUserController {
	
	@Autowired
	private SysUserService sysUserService;
	@Autowired
	private SysRoleService sysRoleService;
	
	
	
	@RequestMapping(value = "/getUser")
	public SysUser getUserInfo(){
		String id = "123";
		SysUser sysUser = sysUserService.selectByPrimaryKey(id);
		return sysUser;
		
	}
	
	@RequestMapping(value = "/getUserList")
	public PageInfo getUserList(HttpServletRequest request){
		 PageInfo<Map<String, Object>> queryUserList = sysUserService.queryUserList(request,null);
		return queryUserList;
		
	}
	
	@RequestMapping(value = "/add")
	public Integer add(HttpServletRequest request){
		SysRole sysRole = new SysRole();
		sysRole.setRole("supAdmin");
		sysRole.setDescription("超级管理员");
		sysRole.setAvailable(true);
		int count = sysRoleService.insertSelective(sysRole);
		return count;
		
	}

}
